package com.idbk.chargestation.amap.base;

import android.os.Bundle;

import com.amap.api.maps.AMap;
import com.amap.api.maps.CameraUpdateFactory;
import com.amap.api.maps.MapView;
import com.idbk.chargestation.R;
import com.idbk.chargestation.base.BaseActivity;

/**
 * 高德地图显示基类
 * Created by zhx on 2017/8/25.
 */

public class BaseMapViewActivity extends BaseActivity {

    public MapView mapView;
    public AMap aMap;

    public void initMapView(Bundle savedInstanceState) {
        mapView = (MapView) findViewById(R.id.map);
        if (mapView != null) {
            mapView.onCreate(savedInstanceState);//必须要写 ,实现地图生命周期管理
            aMap = mapView.getMap();
            if (aMap != null) {
                aMap.getUiSettings().setMyLocationButtonEnabled(false);//设置默认定位按钮是否显示
                aMap.getUiSettings().setTiltGesturesEnabled(false);//禁止倾斜手势
                aMap.getUiSettings().setRotateGesturesEnabled(false);//禁止旋转手势
                aMap.getUiSettings().setZoomControlsEnabled(false);//隐藏缩放按钮
                aMap.animateCamera(CameraUpdateFactory.changeTilt(0));//设定固定倾斜角度
            }
        }
    }


    //缓存页面相关数据
    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        mapView.onSaveInstanceState(outState);
    }

    @Override
    public void onResume() {
        super.onResume();
        mapView.onResume();
    }

    @Override
    public void onPause() {
        super.onPause();
        mapView.onPause();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        mapView.onDestroy();
    }

}
